# -*- coding: utf-8 -*-
import logging
from apscheduler.schedulers.background import BackgroundScheduler
from examples.recorder_utils import run_data_recorder
from examples.report_utils import inform
from zvt import init_log
from zvt.domain import (Stock,
    Stock1dKdata,
    Stock1dHfqKdata,
    Stockhk,
    Stockhk1dKdata,
    Stockhk1dHfqKdata,
    Block,
    Block1dKdata,
    BlockCategory)
from zvt.informer import EmailInformer
from zvt.utils import next_date, current_date
from . utils import set_downloaders

data_provider = "em"
entity_provider = "em"
sleeping_time = 0.1

def record_downloader_1():
    # A股标的
    run_data_recorder(domain=Stock, data_provider=data_provider, force_update=False, sleeping_time=sleeping_time)


def record_downloader_2():    
    # A股前复权行情
    run_data_recorder(
        domain=Stock1dKdata,
        data_provider=data_provider,
        entity_provider=entity_provider,
        day_data=True,
        sleeping_time=sleeping_time,
    )

def record_downloader_2x():    
    # A股后复权行情
    run_data_recorder(
        domain=Stock1dHfqKdata,
        data_provider=data_provider,
        entity_provider=entity_provider,
        day_data=True,
        sleeping_time=sleeping_time,
    )

def record_downloader_3():
    # 板块(概念，行业)
    run_data_recorder(
        domain=Block,
        entity_provider=entity_provider,
        data_provider=entity_provider,
        force_update=False,        
        sleeping_time=sleeping_time)

def record_downloader_4():        
    # 板块行情(概念，行业)
    run_data_recorder(
        domain=Block1dKdata,
        entity_provider=entity_provider,
        data_provider=entity_provider,
        day_data=True,
        sleeping_time=sleeping_time,
    )

def record_downloader_5():
    # 港股标的
    run_data_recorder(domain=Stockhk, data_provider=data_provider, force_update=False, sleeping_time=sleeping_time)

def record_downloader_6():    
    # 港股前复权行情
    df = Stockhk.query_data(filters=[Stockhk.south == True], index="entity_id")
    run_data_recorder(
        domain=Stockhk1dKdata,
        entity_ids=df.index.tolist(),
        data_provider=data_provider,
        entity_provider=entity_provider,
        day_data=True,
        sleeping_time=sleeping_time,
    )

def record_downloader_6x():    
    # 港股后复权行情
    df = Stockhk.query_data(filters=[Stockhk.south == True], index="entity_id")
    run_data_recorder(
        domain=Stockhk1dHfqKdata,
        entity_ids=df.index.tolist(),
        data_provider=data_provider,
        entity_provider=entity_provider,
        day_data=True,
        sleeping_time=sleeping_time,
    )
    
set_downloaders(globals())